package uit.qlks.from;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.rmi.Naming;
import java.sql.ResultSetMetaData;
import java.util.Vector;
import javax.sql.rowset.WebRowSet;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import uit.qlks.controller.phong.PhongController;

public class frmMain extends javax.swing.JFrame {

    public static frmMain _main = new frmMain();

    public frmMain() {
        initComponents();
        this.setResizable(false);
        this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);


    }
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        tpQuanLy = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        tbphong = new javax.swing.JTable();
        javax.swing.JButton btnPhieuDatPhong = new javax.swing.JButton();
        btnIconThoat = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        btnBCDoanhThu = new javax.swing.JButton();
        btnPhieuThuePhong = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        btnPhong = new javax.swing.JButton();
        btnDangKyDichVu = new javax.swing.JButton();
        btnTraCuu = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        btnNguoiDung = new javax.swing.JButton();
        btnConnect = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        mnItemHeThong = new javax.swing.JMenu();
        mnItemDangNhap = new javax.swing.JMenuItem();
        mnItemDangXuat = new javax.swing.JMenuItem();
        mIDoiMatKhau = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        mnItemThoat = new javax.swing.JMenuItem();
        mnItemTroGiup = new javax.swing.JMenu();
        javax.swing.JMenuItem mnItemCauHinh = new javax.swing.JMenuItem();

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("QUẢN LÝ KHÁCH SẠN");
        setAlwaysOnTop(true);
        setFont(new java.awt.Font("Times New Roman", 0, 14));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        tpQuanLy.setFont(new java.awt.Font("Times New Roman", 0, 14));

        jPanel1.setAutoscrolls(true);
        jPanel1.setFont(new java.awt.Font("Times New Roman", 0, 14));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Thông Tin Phòng", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 14))); // NOI18N
        jPanel2.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jPanel2.setName("JPanel2"); // NOI18N

        tbphong.setFont(new java.awt.Font("Times New Roman", 0, 14));
        tbphong.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Tên Phòng", "Tình Trạng"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbphong.getTableHeader().setReorderingAllowed(false);
        jScrollPane9.setViewportView(tbphong);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnPhieuDatPhong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/dangky.png"))); // NOI18N
        btnPhieuDatPhong.setToolTipText("Nhấp vào hình để đăng ký phòng");
        btnPhieuDatPhong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPhieuDatPhongActionPerformed(evt);
            }
        });

        btnIconThoat.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnIconThoat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Exit1.png"))); // NOI18N
        btnIconThoat.setText("Thoát");
        btnIconThoat.setToolTipText("Thoát");
        btnIconThoat.setBorder(null);
        btnIconThoat.setContentAreaFilled(false);
        btnIconThoat.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Exit2.png"))); // NOI18N
        btnIconThoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIconThoatActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jLabel1.setText("Nhóm Sinh Viên UIT");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(38, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnIconThoat, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(btnPhieuDatPhong, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)))
                .addGap(37, 37, 37)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnPhieuDatPhong, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(14, 14, 14)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addComponent(btnIconThoat, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tpQuanLy.addTab("Đăng Ký Phòng", jPanel1);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Nghiệp Vụ Quản Lý", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 14), new java.awt.Color(0, 0, 204))); // NOI18N
        jPanel5.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jPanel5.setName("JPanel2"); // NOI18N

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btnBCDoanhThu.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnBCDoanhThu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/hoadon.png"))); // NOI18N
        btnBCDoanhThu.setText("Báo Cáo Doanh Thu");
        btnBCDoanhThu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBCDoanhThuActionPerformed(evt);
            }
        });

        btnPhieuThuePhong.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnPhieuThuePhong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/phieuthue.png"))); // NOI18N
        btnPhieuThuePhong.setText("Phiếu Thuê Phòng");
        btnPhieuThuePhong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPhieuThuePhongActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnPhieuThuePhong, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
                    .addComponent(btnBCDoanhThu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addComponent(btnBCDoanhThu, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE)
                .addComponent(btnPhieuThuePhong, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btnPhong.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnPhong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/loaiphong.png"))); // NOI18N
        btnPhong.setText("Quản Lý Phòng");
        btnPhong.setActionCommand("Phòng");
        btnPhong.setIconTextGap(1);
        btnPhong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPhongActionPerformed(evt);
            }
        });

        btnDangKyDichVu.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnDangKyDichVu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/phieudichvu.png"))); // NOI18N
        btnDangKyDichVu.setText(" Dịch Vụ");
        btnDangKyDichVu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDangKyDichVuActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnPhong)
                    .addComponent(btnDangKyDichVu, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(btnPhong)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
                .addComponent(btnDangKyDichVu, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37))
        );

        btnDangKyDichVu.getAccessibleContext().setAccessibleName("Dịch Vụ");

        btnTraCuu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Searchpeople.png"))); // NOI18N
        btnTraCuu.setToolTipText("Tra cứu khách hàng");
        btnTraCuu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTraCuuActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addComponent(btnTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel5.getAccessibleContext().setAccessibleName("");

        tpQuanLy.addTab("Nghiệp Vụ Quản Lý", jPanel4);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Nghiệp Vụ Quản Trị", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 0, 14), new java.awt.Color(0, 0, 204))); // NOI18N
        jPanel7.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jPanel7.setName("JPanel2"); // NOI18N

        btnNguoiDung.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnNguoiDung.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/nhanvien.png"))); // NOI18N
        btnNguoiDung.setToolTipText("Quản Trị Nhân Viên");
        btnNguoiDung.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNguoiDungActionPerformed(evt);
            }
        });

        btnConnect.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnConnect.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/connection.png"))); // NOI18N
        btnConnect.setToolTipText("Cấu Hình Hệ Thống");
        btnConnect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConnectActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 18));
        jLabel3.setText("Quản Trị Nhân Viên");

        jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 18));
        jLabel4.setText("Cấu Hình Hệ Thống");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(65, 65, 65)
                        .addComponent(btnNguoiDung, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(81, 81, 81)
                        .addComponent(jLabel3, 0, 0, Short.MAX_VALUE)))
                .addGap(79, 79, 79)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnConnect, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(67, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnNguoiDung, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnConnect, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(38, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel7.getAccessibleContext().setAccessibleName("");

        tpQuanLy.addTab("Nghiệp Vụ Quản Trị", jPanel6);

        mnItemHeThong.setText("Hệ Thống");
        mnItemHeThong.setFont(new java.awt.Font("Times New Roman", 0, 14));
        mnItemHeThong.setName("mnitemHeThong"); // NOI18N

        mnItemDangNhap.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        mnItemDangNhap.setText("Đăng Nhập");
        mnItemDangNhap.setActionCommand("ĐĂNG NHẬP");
        mnItemDangNhap.setName("mnitemDangNhap"); // NOI18N
        mnItemDangNhap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnItemDangNhapActionPerformed(evt);
            }
        });
        mnItemHeThong.add(mnItemDangNhap);

        mnItemDangXuat.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        mnItemDangXuat.setText("Đăng Xuất");
        mnItemDangXuat.setName("mnitemDangXuat"); // NOI18N
        mnItemDangXuat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnItemDangXuatActionPerformed(evt);
            }
        });
        mnItemHeThong.add(mnItemDangXuat);

        mIDoiMatKhau.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        mIDoiMatKhau.setText("Đổi Mật Khẩu");
        mIDoiMatKhau.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mIDoiMatKhauActionPerformed(evt);
            }
        });
        mnItemHeThong.add(mIDoiMatKhau);
        mnItemHeThong.add(jSeparator1);

        mnItemThoat.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        mnItemThoat.setText("Thoát");
        mnItemThoat.setName("mnitemThoat"); // NOI18N
        mnItemThoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnItemThoatActionPerformed(evt);
            }
        });
        mnItemHeThong.add(mnItemThoat);

        jMenuBar1.add(mnItemHeThong);

        mnItemTroGiup.setText("Trợ Giúp");
        mnItemTroGiup.setFont(new java.awt.Font("Times New Roman", 0, 14));
        mnItemTroGiup.setName("mnitemTroGiup"); // NOI18N

        mnItemCauHinh.setFont(new java.awt.Font("Times New Roman", 0, 14));
        mnItemCauHinh.setText("Cấu Hình");
        mnItemCauHinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnItemCauHinhActionPerformed(evt);
            }
        });
        mnItemTroGiup.add(mnItemCauHinh);

        jMenuBar1.add(mnItemTroGiup);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tpQuanLy, javax.swing.GroupLayout.PREFERRED_SIZE, 654, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tpQuanLy, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        tpQuanLy.getAccessibleContext().setAccessibleName("");

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-670)/2, (screenSize.height-377)/2, 670, 377);
    }// </editor-fold>//GEN-END:initComponents

    private void UpdatePhong(JTable jtbDanhSachDV, WebRowSet wrs) {
        try {
            DefaultTableModel dfTable = (DefaultTableModel) jtbDanhSachDV.getModel();
            dfTable.getDataVector().removeAllElements();
            Vector rowData;
            String[] tinhtrang = {"Đã Thuê", "Trống"};
            while (wrs.next()) {
                rowData = new Vector();
                rowData.add(wrs.getString("TenPhong"));
                rowData.add(tinhtrang[wrs.getInt("TinhTrang")]);
                dfTable.addRow(rowData);
            }
            jtbDanhSachDV.setModel(dfTable);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    private void mnItemDangNhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnItemDangNhapActionPerformed
        frmLogin _frm = new frmLogin();
        _main = this;
        _frm.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_mnItemDangNhapActionPerformed

private void mnItemThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnItemThoatActionPerformed
// TODO add your handling code here:
    int result = JOptionPane.showConfirmDialog(this, "Bạn có chắc chắn muốn thoát không?", "Thoát chương trình", 0, 3);
    if (result == JOptionPane.YES_OPTION) {
        this.dispose();
    }
}//GEN-LAST:event_mnItemThoatActionPerformed

private void btnIconThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIconThoatActionPerformed
// TODO add your handling code here:
    int result = JOptionPane.showConfirmDialog(this, "Bạn có chắc chắn muốn thoát không?", "Thoát chương trình", 0, 3);
    if (result == JOptionPane.YES_OPTION) {
        this.dispose();
    }
}//GEN-LAST:event_btnIconThoatActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    int result = JOptionPane.showConfirmDialog(this, "Bạn có chắc chắn muốn thoát không?", "Thoát chương trình", 0, 3);
    if (result == JOptionPane.YES_OPTION) {
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
}//GEN-LAST:event_formWindowClosing

private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
    try
    {
        try
        {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");//set giao dien
        }
        catch(Exception ex){}
        ShowDefault();
//            FileInputStream in = new FileInputStream("./src/quanlykhachsan/config.txt");
//            InputStreamReader isr=new InputStreamReader(in);
//            BufferedReader br=new BufferedReader(isr);
        UpdatePhong(tbphong,PhongController.phong_GetByAll());
    }
    catch(Exception e){
        DefaultTableModel model = (DefaultTableModel) tbphong.getModel();
        for (int i = model.getRowCount() - 1; i >= 0; i--) {
                model.removeRow(i);
        }
        JOptionPane.showMessageDialog(this, "Lỗi kết nối. Vui lòng kiểm tra lại!!!!!!");
//        frmConfig frmcf= new frmConfig();
        _main=this;
//        frmcf.setVisible(true);
//        _frm.setFocusable(true);
        this.dispose();

    }
}//GEN-LAST:event_formComponentShown

private void btnPhongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPhongActionPerformed
// TODO add your handling code here:
        frmPhong frmp = new frmPhong();
        frmp.setVisible(true);
        frmp.setFocusable(true);
        _main = this;
        this.dispose();
}//GEN-LAST:event_btnPhongActionPerformed

private void btnNguoiDungActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNguoiDungActionPerformed
// TODO add your handling code here:
    frmQuanlynguoidung frm = new frmQuanlynguoidung();
    frm.setVisible(true);
    frm.setFocusable(true);
    _main = this;
    this.dispose();
}//GEN-LAST:event_btnNguoiDungActionPerformed
private void ShowDefault() {

    try {
        int role = Integer.parseInt(frmLogin._us.getRole());
        if (role == 2 || role == 1)//admin
        {
            tpQuanLy.setEnabledAt(1, true);
            tpQuanLy.setEnabledAt(2, true);
            mnItemDangNhap.setEnabled(false);
            mIDoiMatKhau.setEnabled(true);
            mnItemDangXuat.setEnabled(true);
        } else {
            tpQuanLy.setEnabledAt(1, false);
            tpQuanLy.setEnabledAt(2, false);
            mnItemDangNhap.setEnabled(true);
            mIDoiMatKhau.setEnabled(false);
            mnItemDangXuat.setEnabled(false);
//        mnItemTroGiup.setEnabled(false);
        }
    } catch (Exception e) {
        tpQuanLy.setEnabledAt(1, false);
        tpQuanLy.setEnabledAt(2, false);
        mnItemDangNhap.setEnabled(true);
        mIDoiMatKhau.setEnabled(false);
        mnItemDangXuat.setEnabled(false);
    }
}

private void mIDoiMatKhauActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mIDoiMatKhauActionPerformed
// TODO add your handling code here:
    frmDoimatkhau frm = new frmDoimatkhau();
    frm.setVisible(true);
    frm.setFocusable(true);
    _main = this;
    this.dispose();
}//GEN-LAST:event_mIDoiMatKhauActionPerformed

private void btnDangKyDichVuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDangKyDichVuActionPerformed
// TODO add your handling code here:
    frmDichVu frmdv = new frmDichVu();
    frmdv.setVisible(true);
//        frmdv.setFocusable(true);
    _main = this;
    this.dispose();
}//GEN-LAST:event_btnDangKyDichVuActionPerformed

private void btnPhieuThuePhongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPhieuThuePhongActionPerformed
// TODO add your handling code here:
    frmPhieuThue frmpt = new frmPhieuThue();
    frmpt.setVisible(true);
    frmpt.setFocusable(true);
    _main = this;
    this.dispose();
}//GEN-LAST:event_btnPhieuThuePhongActionPerformed

private void btnBCDoanhThuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBCDoanhThuActionPerformed
// TODO add your handling code here:
    frmBaoCao frmbc = new frmBaoCao();
    frmbc.setVisible(true);
    frmbc.setFocusable(true);
    _main = this;
    this.dispose();
}//GEN-LAST:event_btnBCDoanhThuActionPerformed

private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
// TODO add your handling code here:
//    frmConfig frmcf = new frmConfig();
//    frmcf.setVisible(true);
//    frmcf.setFocusable(true);
//    _main = this;
//    this.dispose();
}//GEN-LAST:event_btnConnectActionPerformed

private void btnTraCuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTraCuuActionPerformed
// TODO add your handling code here:
    frmTraCuu frmtc = new frmTraCuu();
    frmtc.setVisible(true);
    frmtc.setFocusable(true);
    _main = this;
    this.dispose();
}//GEN-LAST:event_btnTraCuuActionPerformed

private void btnPhieuDatPhongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPhieuDatPhongActionPerformed
// TODO add your handling code here:
    try
    {
//         UserControl usctr = (UserControl)Naming.lookup("rmi://"+config.ServerIP.trim()+":"+config.ServerPort+"/UserControl");
        frmDatPhong frmdp = new frmDatPhong();
        frmdp.preframe = 1;
        frmdp.setVisible(true);
        frmdp.setFocusable(true);
        _main = this;
        this.dispose();
    }
    catch(Exception e)
    {
      JOptionPane.showMessageDialog(rootPane, "Kiểm tra kết nối","Warning", JOptionPane.WARNING_MESSAGE);
//     frmConfig _frm=new frmConfig();
//    _frm.setVisible(true);
//    _frm.setFocusable(true);
    _main=this;
    this.dispose();
    }
}//GEN-LAST:event_btnPhieuDatPhongActionPerformed

private void mnItemDangXuatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnItemDangXuatActionPerformed
// TODO add your handling code here:
    frmLogin._us.setUserName("");
    frmLogin._us.setPassword("");
    frmLogin._us.setRole("-1");
    tpQuanLy.setSelectedIndex(0);
    ShowDefault();
}//GEN-LAST:event_mnItemDangXuatActionPerformed

private void mnItemCauHinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnItemCauHinhActionPerformed
// TODO add your handling code here:
//    frmConfig _frm=new frmConfig();
//    _frm.setVisible(true);
//    _frm.setFocusable(true);
//    _main=this;
//    this.setVisible(false);
//    this.setFocusable(false);
}//GEN-LAST:event_mnItemCauHinhActionPerformed

    public static void main(String args[]) {
        //</editor-fold>
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmMain().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBCDoanhThu;
    private javax.swing.JButton btnConnect;
    private javax.swing.JButton btnDangKyDichVu;
    private javax.swing.JButton btnIconThoat;
    private javax.swing.JButton btnNguoiDung;
    private javax.swing.JButton btnPhieuThuePhong;
    private javax.swing.JButton btnPhong;
    private javax.swing.JButton btnTraCuu;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JMenuItem mIDoiMatKhau;
    private javax.swing.JMenuItem mnItemDangNhap;
    private javax.swing.JMenuItem mnItemDangXuat;
    private javax.swing.JMenu mnItemHeThong;
    private javax.swing.JMenuItem mnItemThoat;
    private javax.swing.JMenu mnItemTroGiup;
    private javax.swing.JTable tbphong;
    private javax.swing.JTabbedPane tpQuanLy;
    // End of variables declaration//GEN-END:variables
}
